package org.example.scenicspot.service;

import org.example.scenicspot.domain.RealtimeInfo;
import org.example.scenicspot.persistence.realtimeInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class realtimeInfoService {
    @Autowired
    realtimeInfoMapper realtimeinfoMapper;
    public List<RealtimeInfo> showrealtimeInfo(){
        return realtimeinfoMapper.selectAll();
    }

    public List<RealtimeInfo> searchrealtimeInfo(String keyword){
        return realtimeinfoMapper.selectByName(keyword);
    }

    public RealtimeInfo selectByID(int id){
        return realtimeinfoMapper.selectByID(id);
    }

    public void insertRealtimeInfo(RealtimeInfo realtimeinfo){
        realtimeinfoMapper.insert(realtimeinfo.getId(),realtimeinfo.getScenicAreaID(),realtimeinfo.getVisitorCount(),realtimeinfo.getAvailableParkingSpaces(),realtimeinfo.getTimestamp());
    }

    public void deleteRealtimeInfo(int ScenicAreaID){
        realtimeinfoMapper.delete(ScenicAreaID);
    }
    public void update(int id,String status){ realtimeinfoMapper.update(status,id);}
}
